@isTest
public class WorkOrderProjectControllerTest
{
    static testMethod void WorkOrderProjectControllerTest()
    {
        ProductStructure__c ps=new ProductStructure__c();
        ps.Classify2__c='尿液-22';
        ps.Classify3__c='试剂';
        ps.Classify1__c='临检';
        insert ps;
        
        ProductProject__c pp=new ProductProject__c();
        pp.Name='项目111';
        pp.ProductStructure__c=ps.Id;
        //pp.Brand__c='迈克生物/maccura';
        insert pp;
        
       
        Product__c product = new Product__c();
        product.Category1__c='临检'; 
        product.Name='全自动尿有形成份分析仪'; 
        product.Category3__c='SYSMEX-XN专用'; 
        product.Category4__c='尿液分析仪'; 
        product.Category2__c='尿液-11'; 
        product.Unit__c='台'; 
        product.SerialNo__c='UF-1000i'; 
        product.Brand__c='济南希森美康'; 
        product.Category0__c='仪器'; 
        product.Model__c='Mdele1';
        product.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('CompetitorProduct', 'Product__c');
        insert product;
        
        Account acc=new Account();
        acc.Name='Test1229J';
        insert acc;
        
        Equipment__c equip = new Equipment__c();
        equip.Product__c=product.Id;
        equip.Account__c=acc.Id;

        insert equip;
        System.debug('仪器'+[select id,Product__c,Account__c from Equipment__c where id = :equip.Id ]);
       
        Case cas=new Case();
        cas.AccountId=acc.Id;
        //cas.ServiceManufacture__c = equip.Id;

        insert cas;
        
        WorkOrder__c wo = new WorkOrder__c();
        //wo.ServiceManufacture__c = equip.Id;

        wo.ServiceInstrumentCP__c = product.Id;
        wo.Case__c = cas.Id;
        wo.Account__c = acc.Id;
        wo.RecordTypeId =  Utils.getRecordTypeIdByDevNameAndObjName('ServiceOrder', 'WorkOrder__c');

        insert wo ;
        System.debug('==工单'+[select id,name,Case__c,Account__c,RecordType.DeveloperName, ServiceManufacture__c from workorder__c where id =: wo.Id]);
        
        WorkOrderItems__c ap=new WorkOrderItems__c();
        ap.WorkOrder__c = wo.Id;
        ap.Items__c = pp.Id;
        insert ap;
        
        
        
         // ---------------------新建-----------------------
        PageReference page = new PageReference('/apex/WorkOrderProject?wid=' + wo.Id);
        System.Test.setCurrentPage(page);
        WorkOrderProjectController apc=new WorkOrderProjectController(new ApexPages.StandardController(new WorkOrderItems__c()));
        apc.init();

        System.assertEquals(1, apc.oldList.size()); 
       // System.assertEquals(1, apc.apList.size()); 

        apc.apList[0].chk = true;
        apc.save1();
        
        
      
    }
}